define(function (require, exports, module) {

  require("mixins/global.mixins.js");
  var mCard = require('andrew/card/index.js');
  var toastr = require("third/toastr/index.js");
  var urlHelper = require("../src/tools/urlHelper.js");

  var param = urlHelper.getUrlParamsMap();


  var api = require('service/api.js');

  var pageVue = new Vue({
    data: {
      chapterList: [],
      formCollapse: false,
      pageSizes: [5, 10, 20, 30],
      currentPage: 1,
      pageSize: 5,
      totalCount: 0,
      bookId: 0
    },
    mounted: function () {
        this.bookId = param.bookId;
        this.getDataList();
    },
    methods: {
        getDataList: function () {
            var curPageVue = this;
            api.getChapterList({
                params: {
                  bookId: curPageVue.bookId,
                  pageSize: curPageVue.pageSize,
                  pageNo:curPageVue.currentPage
                },
                callBack: function (res) {
                    curPageVue.chapterList = res.list;
                    curPageVue.totalCount = res.total;
                    //console.log(res);
                }
            })
        },
        handleSizeChange: function (val) {
            this.pageSize = val;
            this.currentPage = 1;
            this.getDataList();
        },
        handleCurrentChange: function (val) {
            this.currentPage = val;
            this.getDataList();
        }
    }

  }).$mount('#app')
})
